home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Examples / DemoText / UDemoText.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  3.8 KB  |  138 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // UDemoText.cp 
  3. // Copyright © 1986-96 by Apple Computer, Inc. All rights reserved.
  4. //----------------------------------------------------------------------------------------
  5.  
  6. #ifndef __UDEMOTEXT__
  7. #include "UDemoText.h"
  8. #endif
  9.  
  10. // DemoText
  11.  
  12. #ifndef __USCRIPTMENU__
  13. #include "UScriptMenu.h"
  14. #endif
  15.  
  16. // MacApp
  17.  
  18. #ifndef __UMACAPPGLOBALS__
  19. #include "UMacAppGlobals.h"
  20. #endif
  21.  
  22. #ifndef __UMACAPPUTILITIES__
  23. #include "UMacAppUtilities.h"
  24. #endif
  25.  
  26. #ifndef __UMENUMGR__
  27. #include "UMenuMgr.h"
  28. #endif
  29.  
  30. #ifndef __UOSASCRIPT__
  31. #include "UOSAScript.h"
  32. #endif
  33.  
  34. #ifndef __UVIEWSERVER__
  35. #include "UViewServer.h"
  36. #endif
  37.  
  38. #ifndef __UVIEW__
  39. #include "UView.h"
  40. #endif
  41.  
  42. // Toolbox
  43.  
  44. #ifndef __FONTS__
  45. #include <Fonts.h>
  46. #endif
  47.  
  48. //========================================================================================
  49. // CLASS TDemoTextApplication
  50. //========================================================================================
  51. #undef Inherited
  52.  
  53. #if qPowerTalk
  54. #define Inherited TMailingApplication
  55. #else
  56. #define Inherited TApplication
  57. #endif
  58.  
  59. #pragma segment AInit
  60. MA_DEFINE_CLASS_M1(TDemoTextApplication, Inherited);
  61.  
  62. //----------------------------------------------------------------------------------------
  63. // TDemoTextApplication destructor
  64. //----------------------------------------------------------------------------------------
  65. #pragma segment MADestructorRes
  66.  
  67. TDemoTextApplication::~TDemoTextApplication()
  68. {
  69. }
  70.  
  71. //----------------------------------------------------------------------------------------
  72. // TDemoTextApplication::IDemoTextApplication: 
  73. //----------------------------------------------------------------------------------------
  74. #pragma segment AInit
  75.  
  76. void TDemoTextApplication::IDemoTextApplication(void)
  77. {
  78.     CStr255        fontName;
  79.     TTEView*    aTEView;
  80.     
  81. #if qPowerTalk
  82.     this->IMailingApplication(kFileType, kStandardLetterFileType, kSignature);
  83. #else
  84.     this->IApplication(kFileType, kSignature);
  85. #endif
  86.  
  87.     AppendResMenu(MAGetMenu(mFont), 'FONT');
  88.  
  89.     SetStyle(cBold, bold);
  90.     SetStyle(cUnderline, underline);
  91.     SetStyle(cItalic, italic);
  92.     SetStyle(cOutline, outline);
  93.     SetStyle(cShadow, shadow);
  94.     SetStyle(cCondense, condense);
  95.     SetStyle(cExtend, extend);
  96.  
  97.     // Instead of hard-wiring a default text style, get it from the TEView resource    
  98.     FailNIL(aTEView = (TTEView*)gViewServer->DoCreateViews(NULL, NULL, kViewRsrcID, gZeroVPt));
  99.     GetFontName(aTEView->fTextStyle.tsFont, fontName);
  100.  
  101.     // Set up initial text specs 
  102.     TTEDocument::gDefaultSpecs.theTextFont = fontName;
  103.     TTEDocument::gDefaultSpecs.theTextFace = aTEView->fTextStyle.tsFace;
  104.     TTEDocument::gDefaultSpecs.theTextSize = aTEView->fTextStyle.tsSize;
  105.     TTEDocument::gDefaultSpecs.theTextColor = aTEView->fTextStyle.tsColor;
  106.     TTEDocument::gDefaultSpecs.theJustification = aTEView->fJustification;
  107.     TTEDocument::gDefaultSpecs.theBackColor = gRGBWhite;
  108.     aTEView = (TTEView*)FreeIfObject(aTEView);
  109.     
  110.     TScriptMenuBehavior* theScriptMenu = new TScriptMenuBehavior;
  111.     theScriptMenu->IScriptMenuBehavior();
  112.     this->AddBehavior(theScriptMenu);
  113.     
  114. #if qAttachable
  115.     if (fOSAScript != NULL)
  116.         fOSAScript->fNextScriptIdle = 0;
  117. #endif
  118.     
  119. } // TDemoTextApplication::IDemoTextApplication 
  120.  
  121. //----------------------------------------------------------------------------------------
  122. // TDemoTextApplication::DoMakeDocument: 
  123. //----------------------------------------------------------------------------------------
  124. #pragma segment AOpen
  125.  
  126. TDocument* TDemoTextApplication::DoMakeDocument(CommandNumber /* itsCommandNumber */, TFile* itsFile) // override 
  127. {
  128.     TTEDocument* aTEDocument = new TTEDocument;
  129.     
  130.     aTEDocument->ITEDocument(itsFile, kFileType, kWindowRsrcID); 
  131.     return aTEDocument;
  132. } // TDemoTextApplication::DoMakeDocument 
  133.  
  134. //----------------------------------------------------------------------------------------
  135. // End of UDemoText.cp
  136.  
  137. #pragma segment Inline
  138.